<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">

<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="xyzlb-form">
                <input type="hidden" id="deptId" name="deptId">
                <input type="hidden" id="parentId" name="parentId">
                <div class="select-list">
                    <ul>

                        <li>
                            姓    名：<input type="text" name="xingm"/>
                        </li>
                        <li>
                            手机号码：<input type="text" name="sjh"/>
                        </li>
                        <li>
                            身份证号码：<input type="text" name="sfzh"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">

        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>

    </div>
</div>

<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var datas = [[${@dict.getType('sys_user_sex')}]];
    var prefix = ctx + "project/xyzlb";

    $(function() {
        $('body').layout({ west__size: 185 });
        queryDeptTree();
        queryXyzlbList();
    });

    function queryXyzlbList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "学员资料",

            columns: [{
                checkbox: true
            },
                {
                    field : 'studentId',
                    title : '学员id'
                },
                {
                    field : 'deptId',
                    title : '机构ID'
                },
                {
                    field : 'deptName',
                    title : '机构名称'
                },
                {
                    field : 'studentName',
                    title : '姓 名'
                },
                {
                    field : 'sex',
                    title : '性别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                }]
        };
        $.table.init(options);
    }
    function queryDeptTree()
    {
        var url = ctx + "system/dept/rolesDeptTreeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);
        function zOnClick(event, treeId, treeNode) {
            $("#deptId").val(treeNode.id);
            $("#parentId").val(treeNode.pId);
            $.table.search();
        }
    }

    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    $('#btnRefresh').click(function() {
        queryDeptTree();
    });
</script>
</body>
</html>